//
//  FRQAboutTokenshowViewController.m
//  FRQBluetoothKit_Example
//
//  Created by admin on 2023/10/24.
//  Copyright © 2023 xuchunhai. All rights reserved.
//

#import "FRQAboutTokenshowViewController.h"
#import "SupportTableViewCell.h"
#import "FRQTermsofUseViewController.h"
#import "FRQPrivacyPolicyViewController.h"
#import "FRQCookiesPolicyViewController.h"
#import "FRQNoBluetoothYetViewController.h"
@interface FRQAboutTokenshowViewController ()
@property (nonatomic,strong) NSArray *arrTitle;
@property (nonatomic,strong) NSArray *arrVcName;
@end

@implementation FRQAboutTokenshowViewController

-(void)addTableView{
    [self.view addSubview:self.tableView];
    
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_topLayoutGuideBottom);
        make.left.right.mas_equalTo(0);
        make.bottom.mas_equalTo(self.mas_bottomLayoutGuideTop);
    }];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"About Tokenshow";
    [self.view addSubview:self.tableView];
    [self.tableView reloadData];
    self.tableView.backgroundColor=skUIColorFromRGB(0x1c1f2a);
    // Do any additional setup after loading the view.
    
    if (KuserType==0) {
        self.arrTitle=@[@"App Version",
                        @"Device Software",
                        @"Terms of Use",
                        @"Privacy Policies",
                        @"Cookies Policy"];
        self.arrVcName=@[@"FRQAppVersionViewController",@"FRQDeviceSoftwareViewController",@"FRQTermsofUseViewController",@"FRQPrivacyPolicyViewController",@"FRQCookiesPolicyViewController"];
    }else{
        self.arrTitle=@[@"App Version",
                        @"Terms of Use",
                        @"Privacy Policies",
                        @"Cookies Policy"];
        self.arrVcName=@[@"FRQAppVersionViewController",@"FRQTermsofUseViewController",@"FRQPrivacyPolicyViewController",@"FRQCookiesPolicyViewController"];
    }
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark - 代理方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.arrTitle.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 75;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 12;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 65;
}


- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    
    static NSString *cellIdentifier = @"SupportTableViewCell";
    SupportTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = skXibView(@"SupportTableViewCell");
    }
    cell.labTitle.text=self.arrTitle[indexPath.row];
    cell.labTitle.font=[UIFont systemFontOfSize:13];
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSString *vc=self.arrVcName[indexPath.row];
    UIViewController *view=[[NSClassFromString(vc) alloc] init];
    if([vc isEqualToString:@"FRQTermsofUseViewController"]){
        FRQTermsofUseViewController *view=[[FRQTermsofUseViewController alloc] init];
        view.modalPresentationStyle=0;
        [self presentViewController:view animated:YES completion:^{
            
        }];
    }else if ([vc isEqualToString:@"FRQPrivacyPolicyViewController"]){
        FRQPrivacyPolicyViewController *view=[[FRQPrivacyPolicyViewController alloc] init];
        view.modalPresentationStyle=0;
        
        [self presentViewController:view animated:YES completion:^{
            
        }];
    }else if ([vc isEqualToString:@"FRQCookiesPolicyViewController"]){
        FRQCookiesPolicyViewController *view=[[FRQCookiesPolicyViewController alloc] init];
        view.modalPresentationStyle=0;
        
        [self presentViewController:view animated:YES completion:^{
            
        }];
    }else{
        //蓝牙12.01

        if([vc isEqualToString:@"FRQDeviceSoftwareViewController"]){
            if([FRQBluetoothManager shareManager].isConnect == 1){
                [self.navigationController pushViewController:view animated:YES];
            }else{
                FRQNoBluetoothYetViewController *view=[[FRQNoBluetoothYetViewController alloc] init];
                view.typeShow = 2;
                view.modalPresentationStyle=0;
//                [self.navigationController pushViewController:view animated:YES];
                [self presentViewController:view animated:YES completion:^{
                    
                }];
            }
        }else{
            [self.navigationController pushViewController:view animated:YES];
        }
        
    }
    
    
}
@end
